uniform extern float4x4 gWVP;
uniform extern float3 gEyePosW;
uniform extern float3 gAccel;
uniform extern float gTime;
uniform extern int gViewportHeight;


struct InputVS
{
	float3 posL : POSITION0;
	float3 velocity : TEXCOORD0;
	float4 color : COLOR0;
	float startTime : TEXCOORD1;
	float lifeTime : TEXCOORD2;
};

struct OutputVS
{
	float4 posH : POSITION0;
	float4 color : COLOR0;
	float lifeTime : TEXCOORD1;
	float2 tex0 : TEXCOORD0;
	float size : PSIZE;
};

OutputVS ExplosionVS( InputVS IN)
{
	OutputVS outVS;
	
	outVS.posH = mul(float4(IN.posL, 1),gWVP);
	outVS.color = IN.color;
	outVS.tex0 = 0;
	outVS.lifeTime = IN.lifeTime;
	float d = distance(IN.posL, gEyePosW);

	outVS.size = (1000/(d));

	return outVS;
}

float4 ExplosionPS(OutputVS IN) : COLOR
{
	float t = 1/gTime;
	float4 finalColor = IN.color * (t/5);

	if(finalColor.a < 0.03)
		finalColor *= 0;
		//finalColor.a = 0;

	return finalColor;

	//return float4(1,1,1,1);
}

technique Main
{

	pass P0
	{
		vertexShader = compile vs_2_0 ExplosionVS();
		pixelShader = compile ps_2_0 ExplosionPS();

		PointSpriteEnable = true;
		AlphaBlendEnable = true;
		SrcBlend = One;
		DestBlend = One;

		ZWriteEnable = false;
	}

}